package cn.buddha.jec.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName TongBossConfiguration
 * @Author 友野浩二
 * @Date 2020/4/8 10:59
 * @Description 总配置
 * @Version 1.0
 */
@Configuration
@EnableConfigurationProperties(value = TongExceptionProperties.class)
@ConditionalOnProperty(
        prefix = "tong-ex",
        // 从application.properties配置文件中读取属性值
        name = {"enable"},
        // 配置读取的name属性值跟havingValue做比较，如果一样则返回true;否则返回false。
        // 如果返回值为false，则该configuration不生效；为true则生效
        havingValue = "true",
        // 如果没有找到name()中的值就返回false(默认值为false)
        matchIfMissing = false
)
//@Slf4j
public class TongExceptionAutoConfiguration {

    @Bean(initMethod = "init")
    public TongExceptionProperties tongExceptionProperties() {
        return new TongExceptionProperties();
    }

}
